<template>
    <fieldset>
        <legend>Child组件</legend>
        <h1>Child组件</h1>
        <h2>来自父组件的数据:{{g}}</h2>
        <button @click="send">点击传递给父组件</button>
    </fieldset>
</template>

<script>
    export default {
        data(){
            return{
                h:'英雄联盟'
            }
        },
        props:{
            g:{
                type:String
            }
        },
        methods:{
            send() {
                this.$emit('re',this.h)
            }
        },
        beforeCreate(){
            console.log('子组件的beforeCreate');
        },
        created(){
            console.log('子组件的created');
        },
        beforeMount(){
            console.log('子组件的beforeMount');
        },
        // 通过eventBus注册事件
        mounted(){
            console.log('子组件的mounted');
            this.$bus.$on('get',input=>{
                console.log(input);
            })
        },
        beforeDestroy(){
            console.log('子组件的beforeDestroy');
        },
        destroyed(){
            console.log('子组件的destroyed');
        }
    }
</script>